package server

import (
	"chainmaker.org/chainmaker/smarteditor/server/pb/protogo"
	"context"
	"go.uber.org/zap"
)

//contractInvokeServer is the server API for ContractInvoke service.
type contractInvokeServer struct {
	rpcServer *ContractRpcServer
	log       *zap.SugaredLogger
}

//ExecResult invoke contract result
func (cis *contractInvokeServer) ExecResult(ctx context.Context, executeResult *protogo.ExecuteResult) (*protogo.ExecuteResultResponse, error) {
	cis.log.Debugf("[contractInvokeServer ExecResult] accept request. execute result:%s", executeResult.String())

	err := cis.rpcServer.addResponse(executeResult)
	if err != nil {
		cis.log.Debugf("[contractInvokeServer ExecResult] add response to contract prc server fail. execute result:%s", executeResult.String())
		return nil, err
	}
	return &protogo.ExecuteResultResponse{}, nil
}
